<!DOCTYPE html>
<html lang="en">
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
    
    {{context}}
  <body>
    <form id="material3">

                            <table class="table">
                                {% comment %} id任取 {% endcomment %}
                                    <tbody>
                                    <tr>
                                        <td>
                                            <label>采购订单编号：</label>
                                            <label id=''>{{context.po}}</label>
                                        </td>
                                        <td style="width: 350px;">
                                            <label>条目编号：</label>
                                            <label id=''>{{context.itemId}}</label>
                                        </td>
                                        
                                    </tr>
                                    
                        
                            </table>

                            <table class="table">
                                
                                <tbody>
                                    <tr>
                                        <td>
                                            <label>商品编号：</label>
                                            <label id=''>{{context.material_.mname}}</label>
                                        </td>
                                        
                                        <td style="width: 350px;">
                                            <label>库存类型：</label>
                                            <select name="" id="sType">
                                                <option value="1">1</option>
                                                <option value="2">2</option>
                                                <option value="3">3</option>
                                                <option value="4">4</option>
                                            </select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <label>订购订单数量：</label>
                                            <label id=''>{{context.quantity}}</label>
                                        </td>
                                        
                                        <td >
                                            <label>实收数量：</label>
                                            <label id=''><input type="text"  placeholder="placeholder" required></label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <label>收货日期：</label>
                                            <label><input type="text" id="my-input" class="form-control"></label>
                                        </td>
                                        
                                        <td >
                                            <label>过账日期：</label>
                                            <label><input type="text" id="my-input2" class="form-control"></label>
                                        </td>
                                    </tr>

                                </tbody>
                            </table>

                            <table class="table">
                                
                                <tbody>
                                    <tr>
                                        <td>
                                            <label>请对本次交易进行评价：</label>
                                            
                                        </td>
                                        
                                    </tr>
                                    <tr>
                                        <td>
                                            <label>商品质量：</label>
                                            
                                        </td>
                                        
                                        <td>
                                            <label>服务态度：</label>
                                            
                                        </td>
                                        
                                    </tr>
                                    <tr>
                                        <td>
                                           
                                                <input type="hidden" value="1" id="startP">
                                
                                        </td>
                                        <td>
                                            
                                                <input type="hidden" value="2" id="startP2">
                                               
                                        </td>
                                    
                                    </tr>
                                </tbody>
                            </table>
                            <input type="submit">
                        </form>
    <textarea id="item_result"></textarea>
    <script>
        //库存类型下拉框 此处搬了plant的
        //就四个，上次没写

        //提交
        $('#material3').on('submit', function(e) {
            e.preventDefault();
            $.ajax(
            {
                type: "POST",
                url: "{% url 'MM:ajax_create_receipt' %}",
                data:{
                    dataType: "json",
                    csrfmiddlewaretoken: '{{ csrf_token }}',
                    //$("#id").html() 这样取label内的值
                    po_id: '1',
                    oi_id: '1',
                    actualQnty: '10',
                    sType: '3',
                    postTime: '8. 18. 2022', //过帐
                    time: '8. 18. 2022', // 收货
                    qualityScore: '100',
                    serviceScore: '100',
                    //两个评分的id是startP、startP2；两个日期的id是my-input、my-input2；
                },
                success: function(data) {
                    $('#item_result').text(data);
                    var dataObj = eval("("+data+")");
                },
                failure: function() {

                }
            })
        });
    </script>

  </body>
</html>
